package cn.jinjie.day09;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test11 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("zhangsan,15");
        list.add("lisi,18");
        list.add("wangwu,26");
        list.add("xiaoming,19");
        // Stream<Student> st = list.stream().map(
        //         new Function<String, Student>() {
        //             @Override
        //             public Student apply(String s) {
        //                 String[] s1 = s.split(",");
        //                 return new Student(s1[0], Integer.valueOf(s1[1]));
        //             }
        //         }
        // );
        Stream<Student> st = list.stream().map(s -> {
            String[] split = s.split(",");
            return new Student(split[0],Integer.parseInt(split[1]));
        });
        List<Student> st1 = st.collect(Collectors.toList());
        System.out.println(st1);
    }
}
